package ru.ncedu.robot;

import java.util.ArrayList;
import java.util.Collection;

public class Body {
	private final Head head;
	private final Collection<Foot> feet;	
	
	public Body(Head h, Collection<Foot> f){
		head = h;
		feet = f;
		head.setParent(this);
	}
	
	public Collection<Foot> getFeet(){
		return feet;
	}
	
	public static void main(String[] args) {
		Head h = new Head(null);
		Collection<Foot> f = new ArrayList<Foot>();
		for (int i = 0; i < 5; i++){
			Foot temp = new Foot(h, "#" + String.valueOf(i), 0);
			f.add(temp);
		}
		Body body = new Body(h, f);
		body.run();
	}

	private void run() {
		System.out.println("Ready to execute body...");
		(new Thread(head)).start();
		for (Foot i: feet){
			(new Thread(i)).start();
		}
	}

}
